﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using TV_2013.Handle;
using TV_2013.Model;

namespace TV_2013.View
{
    public partial class LessonView : PhoneApplicationPage
    {
        ReadData readData = new ReadData("Data/DataLesson.xml");
        LessonModel lessonModel = new LessonModel();

        public LessonView()
        {
            InitializeComponent();
           
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string id = NavigationContext.QueryString["id"];
            lessonModel = readData.GetDataByAttribute(id,4); // id cua lesson va so luong sound de load
            imgText.Source = new BitmapImage(new Uri(lessonModel.ArrayImage[0], UriKind.Relative));
            img1.Source = new BitmapImage(new Uri(lessonModel.ArrayImage[1], UriKind.Relative));
            img2.Source = new BitmapImage(new Uri(lessonModel.ArrayImage[2], UriKind.Relative));
            img3.Source = new BitmapImage(new Uri(lessonModel.ArrayImage[3], UriKind.Relative));
           
        }

        private void imgText_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            soundLesson.Source = new Uri(lessonModel.ArraySound[0], UriKind.Relative);
            soundLesson.Play();
        }

        private void img1_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            soundLesson.Source = new Uri(lessonModel.ArraySound[1], UriKind.Relative);
            soundLesson.Play();
        }

        private void img2_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            soundLesson.Source = new Uri(lessonModel.ArraySound[2], UriKind.Relative);
            soundLesson.Play();
        }

        private void img3_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            soundLesson.Source = new Uri(lessonModel.ArraySound[3], UriKind.Relative);
            soundLesson.Play();
        }

        //private void imgLesson_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        //{
        //   // soundLesson.Play();
        //}
    }
}